<!-- 优惠活动组件 -->
<template>
  <view class="section">
    <view class="section-header">
      <text class="section-title">优惠活动</text>
      <view class="section-more" @tap="$emit('more')">
        <text class="more-text">查看全部</text>
        <uni-icons type="arrowright" size="14" color="#999"></uni-icons>
      </view>
    </view>
    <view class="promotion-list">
      <view 
        class="promotion-item" 
        v-for="promo in promotions" 
        :key="promo.id"
        @tap="$emit('select', promo)"
      >
        <image :src="promo.image" mode="aspectFill" class="promo-image"></image>
        <view class="promo-info">
          <view class="promo-tag">{{ promo.tag }}</view>
          <text class="promo-title">{{ promo.title }}</text>
          <text class="promo-desc">{{ promo.desc }}</text>
          <view class="promo-footer">
            <text class="promo-time">距结束{{ promo.endTime }}</text>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import type { Promotion } from '../types';

interface Props {
  promotions: Promotion[];
}

defineProps<Props>();
defineEmits(['select', 'more']);
</script>

<style scoped>
.section {
  background-color: #fff;
  margin-bottom: 20rpx;
  padding: 30rpx;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25rpx;
}

.section-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
}

.section-more {
  display: flex;
  align-items: center;
  gap: 5rpx;
}

.more-text {
  font-size: 26rpx;
  color: #999;
}

.promotion-list {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
}

.promotion-item {
  display: flex;
  background-color: #f8f8f8;
  border-radius: 16rpx;
  overflow: hidden;
}

.promo-image {
  width: 200rpx;
  height: 160rpx;
  flex-shrink: 0;
}

.promo-info {
  flex: 1;
  padding: 20rpx;
  display: flex;
  flex-direction: column;
  gap: 8rpx;
}

.promo-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 20rpx;
  color: #fff;
  background-color: #ff3b30;
  padding: 4rpx 12rpx;
  border-radius: 8rpx;
}

.promo-title {
  font-size: 28rpx;
  font-weight: bold;
  color: #333;
}

.promo-desc {
  font-size: 24rpx;
  color: #666;
}

.promo-footer {
  margin-top: auto;
}

.promo-time {
  font-size: 22rpx;
  color: #999;
}
</style>